class @AdminBookListingModel extends ListingModel

    @ListingUrl:''

    initialize: ->
        if AdminBookListingModel.ListingUrl.length==0
            AdminBookListingModel.ListingUrl = SiteMap.Admin.Books.Listing

    defaults:
        Books: []
        Column: "Name"
        Size: 10
        Page: 1
        Direction: 0
        Filter:
            Name: ''
            AuthorId: ''
            AuthorName: ''
            CategoryId: ''
            CategoryName: ''

    url: ->
        url = AdminBookListingModel.ListingUrl
        url += "?page=" + @attributes.Page
        url += "&size=" + @attributes.Size
        url += "&Column=" + @attributes.Column
        url += "&Direction=" + @attributes.Direction
        url += "&Filter.Name=" + @attributes.Filter.Name
        url += "&Filter.AuthorId=" + @attributes.Filter.AuthorId
        url += "&Filter.AuthorName=" + @attributes.Filter.AuthorName
        url += "&Filter.CategoryId=" + @attributes.Filter.CategoryId
        url += "&Filter.CategoryName=" + @attributes.Filter.CategoryName
        SiteMap.Admin.Books.Listing = encodeURI(url)
        return SiteMap.Admin.Books.Listing

    parse: (response) ->
        attrs = {
            Size: response.Size
            Page: response.Page
            TotalPages: response.TotalPages
            Column: response.Column
            Direction: response.Direction
            Filter: @attributes.Filter
        }

        attrs.Books = response.Books
        if response.Filter.Name?
            attrs.Filter.Name = response.Filter.Name
        if response.Filter.AuthorId?
            attrs.Filter.AuthorId = response.Filter.AuthorId
        if response.Filter.CategoryId?
            attrs.Filter.CategoryId = response.Filter.CategoryId
        if response.Filter.AuthorName?
            attrs.Filter.AuthorName = response.Filter.AuthorName
        if response.Filter.CategoryName?
            attrs.Filter.CategoryName = response.Filter.CategoryName

        return attrs
